/***************************************************************************
 *   Copyright (C) 2007 by Sebastian Bilski, Lance Cooper, Jeff Rebacz,
 *   									and Alex Zelenskiy
 *   sbilski@iit.edu
 *   lance.m.cooper@gmail.com
 *   jeff.rebacz@gmail.com
 *   voiceofanarchy@gmail.com
 *
 *	This file is part of connect3
 *
 *   connect3 is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License, version 2,
 *    as published by the Free Software Foundation
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the
 *   Free Software Foundation, Inc., 
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
 ***************************************************************************/

import java.awt.Color;

import junit.framework.TestCase;


public class Test_GamePiece extends TestCase {
	
	public GamePiece p1;
	public GamePiece p2;
	public GamePiece p3;
	public GamePiece p4;
	public GamePiece p5;
	public GamePiece p6;
	
	public Test_GamePiece(String name){
		super(name);
	}
	
	protected void setUp(){
		p1 = new GamePiece();
		p2 = new GamePiece(5, 6, Color.RED);
		p3 = new GamePiece(12345, 4, Color.WHITE);
		p4 = new GamePiece(-1234, 4, Color.BLACK);
		p5 = new GamePiece(0,0,null);
		p6 = new GamePiece(-31, -4312, Color.BLUE);
	}
	
	protected void tearDown(){
	}
	
	public void testDefault(){
		assertTrue(p1.getX()==0);
		assertTrue(p1.getY()==0);
		assertTrue(p1.getColor()!=null);
		assertTrue(p1.getP()!=null);		
	}
	
	public void testRegularAccess(){
		assertTrue(p2.getX()==5);
		assertTrue(p2.getY()==6);
		assertTrue(p2.getColor().equals(Color.RED));
		assertTrue(p2.getP()==null);
	}
	
	public void testBigIntAccess(){
		assertTrue(p3.getX()==12345);
		assertTrue(p3.getY()==4);
		assertTrue(p3.getColor().equals(Color.WHITE));
		assertTrue(p3.getP()==null);
	}
	
	public void testNegativeCase(){
		assertTrue(p4.getX()==0);
		assertTrue(p4.getY()==4);
		assertTrue(p4.getColor()==Color.BLACK);
		assertTrue(p4.getP()==null);
	}
	
	public void test0Case(){
		assertTrue(p5.getX()==0);
		assertTrue(p5.getY()==0);
		assertTrue(p5.getColor()==null);
		assertTrue(p5.getP()==null);
	}
	
	public void testErroneousAccess2(){
		assertTrue(p6.getX()==0);
		assertTrue(p6.getY()==0);
		assertTrue(p6.getColor().equals(Color.BLUE));
		assertTrue(p6.getP()==null);
	}
	
	public void testSetters(){
		Player player = new Player("Tom",Color.YELLOW);
		p1.setP(player);
		p1.setColor(player.getColor());
		p1.setX(3);
		p1.setY(10);

		assertTrue(p1.getX()==3);
		assertTrue(p1.getY()==10);
		assertTrue(p1.getColor().equals(Color.YELLOW));
		assertTrue(p1.getP()==player);	
		
	}

}
